<template>
  <div class="wBd">
    <div class="contArticle">
      <!-- 标题 -->
      <div class="contArticle_tit">
        <h2>{{ honourById.honourTitle }}</h2>
      </div>
      <div class="contArticle_author">
        <span>{{ honourById.createTime }}</span>
        <span>来源：{{ honourById.createBy }}</span>
        <span>（浏览量：{{ honourById.click }}）</span>
      </div>
      <!-- 正文 -->
      <div class="contArticle_text">
        <div id="fontzoom" >
          <div class="qudiaoBorder">
            <div class="ql-editor" v-html="honourById.honourContent"></div>
          </div>
        </div>
<!--        <div style="text-indent: 2rem;" id="fontzoom" v-html="honourById.honourContent"></div>
        <div v-if="honourById.img.length>0" v-for="(item,index) in honourById.img" :key="index">
&lt;!&ndash;          <img style="width: 100%;text-align: center;height: 100%" :src="item.url">&ndash;&gt;
          <img style="width: 100%;text-align: center;height: 100%" :src="changeUrl(item.fileName)">
        </div>-->
      </div>
      <div style="border-top: 1px dotted #ccc;margin-top: 20px;background: none;"></div>
      <div class="contArticle_bot_page">
        <div class="cA_b_prew">
          <span style="color:red">上一篇：</span>
          <a @click="btnClick(upHonour)" v-if="upHonour!=='已是首条'" href="javascript:;"
             :title="'标题：'+upHonour.honourTitle+'\n'+'浏览量：'+upHonour.click+'\n'+'发表时间：'+upHonour.createTime"
          >{{ vague('3', upHonour.honourTitle) }}
            <span style="color: #666;padding-left: 10px;">[ {{ parseTime(upHonour.createTime, '{m}-{d}') }} ]</span>
          </a>
          <span style="color: red" v-else>{{ upHonour }}</span>
        </div>
        <div class="cA_b_next">
          <span style="color:red">下一篇：</span>
          <a @click="btnClick(nextHonour)" v-if="nextHonour!=='已是尾条'" href="javascript:;"
             :title="'标题：'+nextHonour.honourTitle+'\n'+'浏览量：'+nextHonour.click+'\n'+'发表时间：'+nextHonour.createTime"
          >{{ vague('3', nextHonour.honourTitle) }}
            <span style="color: #666;padding-left: 10px;">[ {{ parseTime(nextHonour.createTime, '{m}-{d}') }} ]</span>
          </a>
          <span style="color: red" v-else>{{ nextHonour }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getHonour,getNextHonour,getUpHonour,updateHonourClick } from '@/api/honour'
export default {
  name: 'Edit',
  inject:['reloadMain'],
  data() {
    return {
      honourById: {}, //单条新闻
      upHonour: '已是首条',//上一条新闻
      nextHonour: '已是尾条',  //下一条新闻
    }
  },
  computed: {
    id() {
      return this.$route.query.id
    }
  },
  created() {
    this.getList(this.id)
  },
  methods: {
    getList(id) {
      getUpHonour(id).then(response => {
        if (response.data) {
          this.upHonour = response.data
        } else {
          this.upHonour = '已是首条'
        }
      })
      getNextHonour(id).then(response => {
        if (response.data) {
          this.nextHonour = response.data
        } else {
          this.nextHonour = '已是尾条'
        }
      })
      getHonour(id).then(response => {
        this.honourById = response.data
        // this.honourById.img=this.change(this.honourById.img)
      })
    },
    btnClick(data) {
      updateHonourClick(data);
      this.$router.push({
        path: "/honour/list/edit",
        query: {
          id: data.honourId,
        },
      });
      this.reloadMain();
    }
  }
}
</script>

<style scoped>

</style>
